package com.net.xpay.common.manager.impl.partner;

import com.google.common.base.Preconditions;
import com.net.common.annotation.ReadTransactional;
import com.net.common.dao.BasicMapper;
import com.net.xpay.common.dao.partner.PartnerAccountLogMapper;
import com.net.xpay.common.domain.partner.PartnerAccountLog;
import com.net.xpay.common.manager.partner.PartnerAccountLogManager;
import com.net.common.manager.AbstractManager;
import com.net.xpay.core.enums.AccountBillType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
@ReadTransactional
public class PartnerAccountLogManagerImpl extends AbstractManager<PartnerAccountLog> implements PartnerAccountLogManager{

    @Autowired
    private PartnerAccountLogMapper mapper;


    @Override
    protected BasicMapper<Long, PartnerAccountLog> getMapper() {
        return mapper;
    }

    @Override
    public PartnerAccountLog findByRelatedIdAndType(Long partnerId, Long relatedId, AccountBillType billType) {
        Preconditions.checkArgument(partnerId != null && relatedId != null && billType != null);
        PartnerAccountLog condition = new PartnerAccountLog();
        condition.setPartnerId(partnerId);
        condition.setRelatedId(relatedId);
        condition.setType(billType);
        return getByCondition(condition);
    }

    @Override
    public PartnerAccountLog findLastByType(Long partnerId, AccountBillType type) {
        Preconditions.checkArgument(partnerId != null && type != null);
        return mapper.findLastByType(partnerId, type);
    }
}
